home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
SAT 2.3b4
/
Demo ƒ
/
Collision demo ƒ
/
sApple.p
< prev
next >
Wrap
Text File
|
1995-01-16
|
1KB
|
53 lines
{ Apple sprite for SATcollision }
unit sApple;
interface
uses
{$IFC UNDEFINED THINK_PASCAL}
Types, Quickdraw,
{$ENDC}
SAT;
var
theSound: Handle;
appleFace: FacePtr;
procedure InitApple;
procedure SetupApple (me: SpritePtr);
procedure HandleApple (me: SpritePtr);
implementation
procedure InitApple;
begin
theSound := SATGetSound(128);
appleFace := SATGetFace(132);
end;
procedure SetupApple (me: SpritePtr);
begin
me^.speed.h := 1 + SATRand(3);
me^.kind := -1; {Enemy kind}
me^.face := appleFace;
SetRect(me^.hotRect, 0, 0, 32, 32);
me^.task := @HandleApple; {Must have a handling routine}
end;
procedure HandleApple (me: SpritePtr);
begin
if me^.kind <> -1 then {Something hit us!}
begin
SATSoundPlay(theSound, 1, false);
me^.task := nil; {Go away}
end;
{Move}
me^.position.h := me^.position.h + me^.speed.h;
if me^.position.h > gSAT.offSizeH - 16 then
me^.speed.h := -1 - SATRand(3);
if me^.position.h < -16 then
me^.speed.h := 1 + SATRand(3);
end;
end.